package com.muyu.cloud.commodity.mapper;

import com.muyu.cloud.commodity.domain.req.ProductReq;
import com.muyu.cloud.commodity.domain.model.Product;
import com.muyu.cloud.commodity.domain.resp.ProductVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @
 * @descriptions: ProductMapper
 * @author: LiuSuo
 * @date: 20:03
 * @version: 1.0
 */
@Mapper
public interface ProductMapper{
    /**
     * 总页数
     * @param productReq
     * @return
     */
    Integer countByPage(ProductReq productReq);

    /**
     * 商品列表
     * @param productReq
     * @return
     */
    List<ProductVo> selectByPage(ProductReq productReq);

    /**
     * 商品详情
     * @param id
     * @return
     */
    Product selectDetailById(@Param("id") Long id);

    void updateById(Product product);

    List<Long> selectSkuIdsByProductId(@Param("productId") Long productId);

    void deleteBySkuIds(@Param("skuIds") List<Long> skuIdsToDelete);

    void deleteByIds(List<Long> skuIdsToDelete);

    Product selectById(@Param("productId") Long productId);

    List<String> selectExistingSkuCodes(List<String> skuCodes);

    void insert(Product product);

    /**
     * 更新商品状态
     */
    int updateStatusById(@Param("id") Long id, @Param("status") Integer status);

    /**
     * 插入商品并返回主键
     */
    int insertReturnId(Product product);

    /**
     * 批量根据ID查询商品
     */
    List<Product> selectBatchIds(List<Long> ids);

}
